package com.icodingedu.springcloud.hystrix;

import com.icodingedu.springcloud.pojo.PortInfo;
import com.icodingedu.springcloud.service.MyService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class Fallback implements MyService {

    @Override
    @HystrixCommand(fallbackMethod = "fallback2")
    public String error() {
        log.info("****** sorry *******");
        throw new RuntimeException("first fallbacl");
    }
    @HystrixCommand(fallbackMethod = "fallback3")
    public String fallback2(){
        log.info("****** sorry again *******");
        throw new RuntimeException("first fallbacl again");
    }

    public String fallback3(){
        log.info("****** sorry again 2 人工干预 *******");
        return "success sorry again 2";
    }

    @Override
    public String sayHello() {
        return null;
    }

    @Override
    public PortInfo sayHello(PortInfo portInfo) {
        return null;
    }

    @Override
    public String retry(int timeout) {
        return "You are late ......!";
    }

}
